export const Local = {
    get(key:string){
        let val = localStorage.getItem(key)
        return val ? JSON.parse(val) : null
    },
    /**
     * 
     * @param key 
     * @param value 
     * @returns 
     */
    set(key:string,value:any){
        return localStorage.setItem(key,JSON.stringify(value))
    },
    remove(key:string){
        localStorage.removeItem(key)
    },
    clear(){
        localStorage.clear()
    }
}

export const Session = {
    get(key:string){
        let val = sessionStorage.getItem(key)
        return val ? JSON.parse(val) : null
    },
    /**
     *
     * @param key
     * @param value 需转换JSON传递
     * @returns
     */
    set(key:string,value:any){
        return sessionStorage.setItem(key,JSON.stringify(value))
    },
    remove(key:string){
        sessionStorage.removeItem(key)
    },
    clear(){
        sessionStorage.clear()
    }
}